<?php

namespace co2\dev\v0_0_0\bash;

use co2\dev\v0_0_0 as co2;

class chmod extends co2\bash

{
	public function
	__construct
	(
		$file,
		$owner,
		$group,
		$other,
		$recursive=false
	)
	
	{
		$this->cmd='chmod ';
		
		if($recursive)
		$this->cmd.'-R ';
		
		/*
			execute 1
			write		2
			read		4
			
		 */
			
		
		foreach(array('owner','group','other') as $_)
		
		{
			$r=0;
			
			if(${"$_"}[0])
			$r+=4;
			
			if(${"$_"}[1])
			$r+=2;
			
			if(${"$_"}[2])
			$r++;
			
			$this->cmd.=$r;
		}
		
		$this->cmd.=' '.$file;
		
		$this->exec();
	}
}
